﻿@{
    ViewBag.Title = "List";
    Layout = "~/Views/Shared/layoutCommon.cshtml";
}

@section style{
    <style>
        /*一行省略 */
        .ellipsis {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
    </style>
}
<section class="content-header">
    <h1>
        消息管理
        <small></small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i>主页</a></li>
        <li class="active">消息管理</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">

                <div class="box-header">
                    <div class="form-inline">
                        <div class="form-group">
                            <label>消息标题</label>
                            <input type="text" class="form-control" style="width:100px;" maxlength="20" id="msgTitle" autocomplete="off" />
                        </div>
                        <div class="form-group">
                            <label>操作人ID</label>
                            <input type="text" class="form-control" style="width:100px;" maxlength="20" id="opId" autocomplete="off" />
                        </div>
                        <div class="form-group">
                            <label>消息类别</label>
                            <select class="form-control" style="width:150px;" id="msgType">
                                <option value="-1">请选择</option>
                                <option value="1">预约</option>
                                <option value="2">通知消息</option>
                                <option value="3">其他</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>消息来源</label>
                            <select class="form-control" style="width:150px;" id="msgSource">
                                <option value="-1">请选择</option>
                                <option value="1">系统自动</option>
                                <option value="2">OP系统</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>是否发送</label>
                            <select class="form-control" style="width:150px;" id="isSend">
                                <option value="-1">请选择</option>
                                <option value="1">已发送</option>
                                <option value="0">未发送</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <button type="button" class="btn btn-success btn-sm" id="btnSearch">查找</button>
                        </div>
                        <div class="form-group">
                            <button type="button" class="btn btn-success btn-sm" id="btnAdd">添加消息</button></li>
                        </div>
                        <h3 class="box-title"></h3>
                    </div>
                </div>
                <div id="datatable">


                </div>
            </div>

        </div>
</section>
@section scriptsBottom{
    <script type="text/javascript">
        $(document).ready(function () {
            search();
            $("#btnSearch").on('click', function () { search(); })
            $("#btnAdd").click(function () {
                add();
            });
        });
        //页码
        var pageIndex = 1;
        //查询
        function search() {
            var data = {
                MessageTitle: $("#msgTitle").val(),
                MessageType: $("#msgType").val(),
                MessageSource: $("#msgSource").val(),
                IsSend: $("#isSend").val(),
                OPID: $("#opId").val(),
                rows: 10,
                page: pageIndex
            }
            $("#datatable").load('@Url.Action("PartialListDataView", "Message")', data, function (data) {
                document.getElementById('datatable').innerHTML = data;
                //分页显示
                $('#pagination').twbsPagination("destroy");
                $('#pagination').twbsPagination({
                    totalItems: $("#dataView").data("count"),
                    visiblePages: 10,
                    pageSize: 10,
                    startPage: parseInt(pageIndex),
                    onPageClick: function (event, page) {
                        pageIndex = page;
                        search();
                    }
                });
            })
        };
        function add() {
            var url = '@Url.Action("Add", "Message")';
            BMCW.showTopLayer("添加消息", url, 630, 600);
        }
    </script>
}
